package com.heima.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
 
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

import com.alibaba.fastjson.JSON;
import com.heima.YongYouUtil;

/**
 * 身份证二要素
 */
public class JavaDemo {

    //配置您申请的KEY
    public static final String APICODE ="b3b7fbb87b8d45229fbcf5d379676b7f";
 
    //1.API方法
    public static void getRequest(String idNumber,String userName){
        String result =null;
        String url ="https://api.yonyoucloud.com/apis/dst/matchIdentity/matchIdentity";//请求接口地址
        String method = "POST";
        String paramFormat = "form";
        Map<String, Object> params = new HashMap<String, Object>();//请求参数
        params.put("idNumber", idNumber);
        params.put("userName", userName);
 
        Map<String, Object> headerParams = new HashMap<String, Object>();//请求头参数
        headerParams.put("apicode", APICODE);//APICODE
        headerParams.put("Content-Type", "application/json");
 
        try {
            result = YongYouUtil.net(url, params, headerParams, method, paramFormat);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String idNumber="210103195103222113"; //身份证正面
        String userName="王东镇1";  //用户真实名字
        getRequest(idNumber,userName);
    }
}